/*
 * Copyright (c) 2010-2011 Plugger Antonio Begue Ponce. All Rights Reserved.
 *
 * This file is part of Plugger Framework.
 *
 *  Plugger Framework is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License version 3 as published by
 *  the Free Software Foundation.
 *
 *  Plugger Framework is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Plugger Framework.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.plugger.infrastructure.repositorybase;

import java.util.List;
import org.plugger.infrastructure.domainbase.IAggregateRoot;

/**
 * A generic interface that defines a repository.<BR/>
 * Only an AggregateRoot can be used to create a repository.<BR/>
 * The repository uses a workspace (unit of work) to retrieve entities from persistence.<BR/>
 * Each entity is responsible to retrieve theirs value objects.<BR/>
 * Every database query should be stored inside the respective repository.
 *
 * @author Antonio Begue
 * @version $Revision: 1.0 $
 *
 * @see     RepositoryBase
 * @see     IWorkspace
 */
public interface IRepository<T extends IAggregateRoot> {
    /**
     * Retrieve an entity from persistence using the entity key.
     *
     * @param id the entity key.
     * @return an entity of type T.
     */
    T getById(Object id);

    /**
     * Retrieve all the entities of type T from persistence.
     *
     * @return a list of T.
     */
    List<T> getAll();

    /**
     * Add an entity to persistence.
     *
     * @param item The entity to be added to persistence.
     */
    void add(T item);

    /**
     * Remove an entity from persistence.
     *
     * @param item The entity to be removed from persistence.
     */
    void remove(T item);
}
